package com.offices.subscribe.dto.message;

import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import lombok.Data;

import java.util.Map;

/**
 * BaseMessage class
 *
 * @author keriezhang
 * @date 2016/10/31
 */
@Data
@JacksonXmlRootElement(localName = "xml")
public class BaseMessage {

    @JacksonXmlProperty(localName = "ToUserName")
    private String toUserName;
    @JacksonXmlProperty(localName = "FromUserName")
    private String fromUserName;
    @JacksonXmlProperty(localName = "CreateTime")
    private long createTime;
    @JacksonXmlProperty(localName = "MsgType")
    private String msgType;

    public BaseMessage(Map<String, String> request) {
        this.toUserName = request.get("FromUserName");
        this.fromUserName = request.get("ToUserName");
        this.createTime = System.currentTimeMillis()/1000;
    }
}
